package com.tansun.easycare.rule.rulelog.entity;

import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.Length;

import com.alibaba.fastjson.JSON;
import com.tansun.easycare.rule.common.entity.RuleBaseEntity;

/**
 * 规则日志Entity
 * @author lph
 * @version 2018-07-23
 */
public class RuleLogs extends RuleBaseEntity<RuleLogs> {
	
	private static final long serialVersionUID = 1L;
	private String projectCode;		// 项目编码
	private String ruleflowid;		// 规则流ID
	private String ruleflowCode;    // 规则流Code
	private String version;			// 规则流版本
	private String enterPointer;    // 调用编码  注：当logType为2时， enterPointer是测试模型ID
	private String runTime;		    // 执行时间
	private String issuccess;		// 成功标志
	private String ruleParam;		// 规则入参
	private String ruleResult;		// 规则结果
	private String logContent;		// 执行日志
	private String exceptionType;	// 异常类型
	private String exceptionMsg;	// 异常信息
	private String logType;			// 测试标识 1:正式数据，2：测试数据  对比测试结果标志
	private String batchNo;			// 批次号  一次调用存在正式数据，也还会有挑战者数据，需要用批次号做一个关联
	private String count;			// 饼状图的数据，统计计数
	private String avtTime;			// 执行时间
	private String totalCount;		// 用于分组统计计数，总计
	private String projectName;		// 项目名称
	private String modelName;		// 模型名称 
	private String beginDate;         // 查询开始时间
	private String endDate;           // 查询结束时间
	private List<Map<String, Object>> logs;
	private String testBranchName;  // 测试分支名称
	private String finalResult;		// 约定的变量，通过P，拒绝R，线下核实V
	private String reasonCodeList;	// 约定的参数，原因代码列表
	
	public RuleLogs() {
		super();
	}
	public RuleLogs(String id,String projectCode,String enpterPointer,String ruleParam) {
		this.setId(id);
		this.setProjectCode(projectCode);
		this.setEnterPointer(enpterPointer);
		this.setRuleParam(ruleParam);
		this.setIssuccess("1");
	}
	public String getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(String beginDate) {
		this.beginDate = beginDate;
	}

	public String getEndDate() {
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}


	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		this.projectName = projectName;
	}

	public String getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(String totalCount) {
		this.totalCount = totalCount;
	}

	public String getAvtTime() {
		if(StringUtils.isEmpty(avtTime))
			return "";
		Double d = new Double(avtTime);
		DecimalFormat dFormat=new DecimalFormat("#.00");
		return dFormat.format(d);
	}

	public void setAvtTime(String avtTime) {
		this.avtTime = avtTime;
	}

	public String getCount() {
		return count;
	}

	public void setCount(String count) {
		this.count = count;
	}

	public RuleLogs(String id){
		super(id);
	}

	@Length(min=1, max=50, message="project_code长度必须介于 1 和 50 之间")
	public String getProjectCode() {
		return projectCode;
	}

	public void setProjectCode(String projectCode) {
		this.projectCode = projectCode;
	}
	
	@Length(min=0, max=64, message="ruleflowid长度必须介于 0 和 64 之间")
	public String getRuleflowid() {
		return ruleflowid;
	}

	public void setRuleflowid(String ruleflowid) {
		this.ruleflowid = ruleflowid;
	}
	
	@Length(min=0, max=50, message="enter_pointer长度必须介于 0 和 50 之间")
	public String getEnterPointer() {
		return enterPointer;
	}

	public void setEnterPointer(String enterPointer) {
		this.enterPointer = enterPointer;
	}
	
	@Length(min=0, max=10, message="run_time长度必须介于 0 和 10 之间")
	public String getRunTime() {
		return runTime;
	}

	public void setRunTime(String runTime) {
		this.runTime = runTime;
	}
	
	@Length(min=0, max=10, message="issuccess长度必须介于 0 和 10 之间")
	public String getIssuccess() {
		return issuccess;
	}

	public void setIssuccess(String issuccess) {
		this.issuccess = issuccess;
	}
	
	public String getRuleParam() {
		return ruleParam;
	}

	public void setRuleParam(String ruleParam) {
		this.ruleParam = ruleParam;
	}
	
	public String getRuleResult() {
		return ruleResult;
	}

	public void setRuleResult(String ruleResult) {
		this.ruleResult = ruleResult;
	}
	
	public String getLogContent() {
		return logContent;
	}

	public void setLogContent(String logContent) {
		this.logContent = logContent;
	}
	
	@Length(min=0, max=32, message="exception_type长度必须介于 0 和 32 之间")
	public String getExceptionType() {
		return exceptionType;
	}

	public void setExceptionType(String exceptionType) {
		this.exceptionType = exceptionType;
	}
	
	public String getExceptionMsg() {
		return exceptionMsg;
	}

	public void setExceptionMsg(String exceptionMsg) {
		this.exceptionMsg = exceptionMsg;
	}

	public String getLogType() {
		return logType;
	}
	public void setLogType(String logType) {
		this.logType = logType;
	}
	public String getRuleflowCode() {
		return ruleflowCode;
	}

	public void setRuleflowCode(String ruleflowCode) {
		this.ruleflowCode = ruleflowCode;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public String getModelName() {
		return modelName;
	}

	public void setModelName(String modelName) {
		this.modelName = modelName;
	}
	public List<Map<String, Object>> getLogs() {
		return logs;
	}
	public void setLogs(List<Map<String, Object>> logs) {
		this.setLogContent(JSON.toJSONString(logs));
		this.logs = logs;
	}
	public String getBatchNo() {
		return batchNo;
	}
	public void setBatchNo(String batchNo) {
		this.batchNo = batchNo;
	}
	public String getTestBranchName() {
		return testBranchName;
	}
	public void setTestBranchName(String testBranchName) {
		this.testBranchName = testBranchName;
	}
	public String getFinalResult() {
		return finalResult;
	}
	public void setFinalResult(String finalResult) {
		this.finalResult = finalResult;
	}
	public String getReasonCodeList() {
		return reasonCodeList;
	}
	public void setReasonCodeList(String reasonCodeList) {
		this.reasonCodeList = reasonCodeList;
	}
	
	
}